// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App'
import Home from './pages/index'
import saved from './components/saved'
import saving from './components/saving'
import statistics from './components/statistics'

import {
  AlertPlugin,
  ToastPlugin,
  ConfirmPlugin
} from 'vux'
Vue.use(AlertPlugin);
Vue.use(ToastPlugin);
Vue.use(ConfirmPlugin);

Vue.use(VueRouter)

const routes = [{
  path: '/',
  component: Home,
  children: [{
      path: '/',
      component: saved
    },
    {
      path: '/saving',
      component: saving
    },
    {
      path:'/statistics',
      component:statistics,
      name:'statistics'
    }
  ]
}]

const router = new VueRouter({
  routes
})

FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app-box')


/**
 * 一些全局配置
 */
//防止页面后退
// history.pushState(null, null, document.URL);
// window.addEventListener('popstate', function () {
//   history.pushState(null, null, document.URL);
// });

document.addEventListener('backbutton', function (e) {
    //阻止后退
    event.preventDefault();
});




/**
 * 常用方法
 */

//移除数组中某一元素
Array.prototype.remove = function (val) {
  var index = this.indexOf(val);
  if (index > -1) {
    this.splice(index, 1);
  }
};
//向数组中插入
Array.prototype.insert = function (index, item) {
  this.splice(index, 0, item);
};
